<!DOCTYPE HTML>
<html lang="zh-CN"><head>
<title>{$name}</title>
<meta charset="UTF-8">
<meta name="viewport" content=" initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link href="{$Think.config.RESOURCEURL}wx_assets/bootstrap/bootstrap.min.css" rel="stylesheet">
<link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
<link href="{$Think.config.RESOURCEURL}wx_assets/css/product/evaluation.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
<link href="{$Think.config.RESOURCEURL}wx_assets/indiana/style.css" rel="stylesheet">
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share_byhyj.js{$Think.config.RESOURCE_VER}"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/product/indiana.js" type="text/javascript"></script>		
<style>
@font-face {
  font-family: 'iconfont';
  src: url('//at.alicdn.com/t/font_1460532199_649201.eot'); /* IE9*/
  src: url('//at.alicdn.com/t/font_1460532199_649201.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
  url('//at.alicdn.com/t/font_1460532199_649201.woff') format('woff'), /* chrome、firefox */
  url('//at.alicdn.com/t/font_1460532199_649201.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
  url('//at.alicdn.com/t/font_1460532199_649201.svg#iconfont') format('svg'); /* iOS 4.1- */
}
</style>
</head>
<body style="background: #efeff4;">
<input type="hidden" value='{$Think.config.RESOURCEURL}wx_assets/images/defaultHeadImg.png{$Think.config.RESOURCE_VER}' id="defaultImg"/>
	<header class="main" >
			<div class="ui-top child">
				<a onclick="history.go(-1);" class="ui-tBtn"><i class="iconfont">&#xe60a;</i></a>
				<div class="middle">
					晒单分享
				</div>
			</div>
	</header>
	<ul class="ui-comnt-list" >
		<volist name="list" id="lt" offset="0" length='10'>
			<li>
				<div class="media" >
					  <div class="media-left">
					  	 <empty name="lt.headImgUrl">
					  	 	 <img class="media-object" src="{$Think.config.RESOURCEURL}wx_assets/images/defaultHeadImg.png{$Think.config.RESOURCE_VER}">
					  	 	<else />
					  	 	<img class="media-object" src="{$lt.headImgUrl}">
					  	 </empty>
					      
					  </div>
					  <div class="media-body" style="vertical-align: middle;">
					    <h2 class="media-heading">
					    	<empty name="lt.nickName">
					    		匿名用户
					    		<else />
					    		{$lt.nickName}
					    	</empty>
					    	
					    	<span>{$lt.createTime}</span>
					    </h2>
					    
					  </div>
				</div>
				<div class="comnt-text">
					{$lt.comment}
				</div>
				<div class="comnt-img">
					<volist name="lt.imgurl" id="imgs">
						<div>
							<img src="{$imgs}@320h_320w_1e_1c"/>
						</div>
					</volist>
				</div>
			</li>
		</volist>
	</ul>
	<div class="gethState" style="margin-bottom: 10px;">
		来晒单嘛！有了你，我就不再孤独！
	</div>
	
<script type="text/javascript">

var imgs='';
wx_share.init({
	"title":"",
    "desc":'',
    "link":'',
    "imgUrl":"{$picUrl}",
    "pkg":{
        "appId": '{$pkg.appId}',
        "timestamp": {$pkg.timestamp},
        "nonceStr": '{$pkg.nonceStr}',
        "signature": '{$pkg.signature}'
    }
});

var showImg=function(){
	$('.ui-comnt-list li .comnt-img').each(function(){
		var imgs=new Array;
		$(this).children().each(function(){
			var _index=$(this).find('img').attr('src').split('@')[0];
			imgs.push(_index);
		})
		$(this).children().unbind('click');
		$(this).children().on('click',function(){
			
			var activeImg=$(this).find('img').attr('src').split('@')[0];
			console.log(imgs+','+activeImg);
			wx_share.showImg(imgs,activeImg);
		})
	});
}

showImg();

var comntlist={
	option:{
		isAll:false,
		start:10,
		limit:10,
		count:1,
		defaultLimit:10
	},
	init:function(){

		if($('.ui-comnt-list > li').length < this.option.defaultLimit)
		{
			$('.gethState').show();
			this.option.isAll=true;
		}
	},
	//获取该期所有用户的参与记录
	getCommentList:function(){
		var _this=this,
		start=this.option.count*this.option.limit,
		limit=this.option.limit;
		var customerId=$.util.getParam('customerId'),
			oid=$.util.getParamAsObject().oid,
			pid=$.util.getParamAsObject().pid,
			params={
				"oid":oid,
				"pid":pid,
				"start":start,
				"limit":limit
			};
			_url=Indiana.getUrl("json","product","getcommentList",params);
			console.log(_url);
			
			//采用同步方式，避免第一次加载与滑到底部重复
			$.ajax({
				url:_url,
				type:"GET",
				dataType:"JSON",
				beforeSend:function(){
					 $.util.pageLoading.show('加载更多...');
				},
				success:function(data){
					 $.util.pageLoading.hide();
					data=eval('('+data+')');
					data=data.list;
					
					if(data.length==0)
					{
//						alert('没有更多数据了')
						$('.gethState').show();
						_this.option.isAll=true;
					}
					else
					{
						//填充数据ui-history-db
						for(var i=0;i<data.length;i++)
						{
							console.log(data[i].headImgUrl);
							var imgurl=data[i].headImgUrl!=''&&data[i].headImgUrl!=null?data[i].headImgUrl:$('#defaultImg').val(),
								nickName=data[i].nickName!=''&&data[i].nickName!=null?data[i].nickName:'匿名用户';
							var comnt_img='';
							for(var y=0;y<data[i].imgurl.length;y++)
							{
								comnt_img=comnt_img+'<div><img src="'+data[i].imgurl[y]+'@320h_320w_1e_1c" /></div>';
							}
							
							var li='<li>'
										+'<div class="media" >'
											  +'<div class="media-left">'
											     +'<img class="media-object" src="'+imgurl+'">'
											  +'</div>'
											  +'<div class="media-body" style="vertical-align: middle;">'
											    +'<h2 class="media-heading">'
											    	+nickName
											    	+'<span>'+data[i].createTime+'</span>'
											    +'</h2>'
											    
											  +'</div>'
										+'</div>'
										+'<div class="comnt-text">'
											+data[i].comment
										+'</div>'
										+'<div class="comnt-img">'
											+comnt_img
										+'</div>'
									+'</li>';
							$('.ui-comnt-list').append(li);
							console.log(li);
							showImg();
						}
						_this.option.count++;
						if(data.length<limit)
						{
							$('.gethState').show();
							_this.option.isAll=true;
						}
					}
				}
			})
		
	},
	checkBottom:function(){
		
		Indiana.goTopScroll();
		var _this=this;
		var s=this.option.start,l=this.option.limit;
//		_this.getCommentList();
		$(window).scroll(function(){
		　　var scrollTop = $(this).scrollTop();
		　　var scrollHeight = $(document).height();
		　　var windowHeight = $(this).height();
		　　if(scrollTop + windowHeight == scrollHeight){
			 if(!_this.option.isAll)
			 {
			 	_this.getCommentList();
			 }　
		　　}
		});
		
	}
}
$(function(){
	comntlist.init();
	comntlist.checkBottom();
})

</script>
</body>
</html>
